﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HYRN.Common.FileUtilities
{
    public static class TxtHelper
    {
        /// <summary>
        /// 读取txt文件内容
        /// </summary>
        /// <param name="Path">文件地址</param>
        public static string ReadTxtContent(string Path)
        {
            StreamReader sr = new StreamReader(Path, Encoding.UTF8);

            string outStr = "";
            string content;
            while ((content = sr.ReadLine()) != null)
            {
                outStr = outStr + content;
                Console.WriteLine(content.ToString());
            }

            return outStr;
        }


        public static void SaveTxt(string path, string content)
        {
            //写入2：

            File.WriteAllText(path, content);
            // 也可以指定编码方式 
            // File.WriteAllText(@"c:\temp\test\a.txt", str1, Encoding.ASCII);
        }

    }
}
